// 管理后台类型定义

export interface AdminUser {
  id: string;
  username: string;
  email: string;
  role: "admin" | "user"; // API使用'user'而不是'editor'
  status: "active" | "inactive";
  avatar: number; // 头像文件ID（用于存储）
  avatar_url: string; // 头像URL（用于显示）
  createdAt: string;
  updatedAt: string;
  lastLogin?: string;
}

export interface AdminCategory {
  id: string;
  name: string;
  slug: string;
  description?: string;
  status: "active" | "inactive";
  color?: string;
  icon?: string;
  postCount: number;
  createdAt: string;
  updatedAt: string;
}

export interface AdminTag {
  id: string;
  name: string;
  slug: string;
  color?: string;
  status: "active" | "inactive";
  postCount: number;
  createdAt: string;
  updatedAt: string;
}

export interface AdminPost {
  id: string;
  title: string;
  slug: string;
  content: string;
  excerpt: string;
  author: AdminUser;
  category: AdminCategory;
  tags: AdminTag[];
  coverImage?: string;
  readTime: number;
  views: number;
  likes: number;
  status: "published" | "draft" | "archived";
  publishDate?: string;
  createdAt: string;
  updatedAt: string;
}

export interface DashboardStats {
  totalPosts: number;
  totalCategories: number;
  totalTags: number;
  totalUsers: number;
  publishedPosts: number;
  draftPosts: number;
  activeUsers: number;
  posts: {
    total: number;
    thisMonth: number;
  };
  comments: {
    total: number;
    pending: number;
  };
  views: {
    total: number;
    today: number;
    weekly: number[];
  };
  users: {
    total: number;
    thisMonth: number;
  };
  recentActivity: Array<{
    type: "post" | "user" | "category";
    action: "created" | "updated" | "deleted";
    title: string;
    time: string;
  }>;
}

export interface ProjectStats {
  total: number;
  active: number;
  completed: number;
  archived: number;
  recent: number;
}

export interface AdminProject {
  id: string;
  title: string;
  slug: string;
  description: string;
  content: string;
  cover_image_id: number;
  cover_image_url: string;
  status: "draft" | "published" | "inProgress" | "archived";
  priority: "low" | "medium" | "high";
  startDate?: string;
  endDate?: string;
  tags: string[];
  technologies: string[];
  demoUrl?: string;
  githubUrl?: string;
  created_at: string;
  updated_at: string;
  category: string;
  categoryId: string;
  featured?: boolean;
  views?: number;
}
